#
# Run experiments for diploma thesis (known kernels).
#

use strict;
use warnings;

my $home = 'C:\Users\ungerma\Desktop\DA\dual-process-model\dpm';
my $run = "$home\\dist\\Debug\\MinGW-Windows\\dpm.exe ";
my $additional = '-# 3000 -m 512';

sub printRun {
  my $cmd = shift;
  print "$cmd\n";
  return system($cmd);
}

printRun($run . 'features') == 0 or die('Could not run cmd');
for my $k (0, 1, 2, 3) {
  printRun($run . "train \"-t $k $additional\"");
  printRun($run . "classify");
  opendir D, "$home\\gen" or die "Could not open dir: $!\n";
  my @files = grep(/pr\d+/i, readdir D);
  closedir D;
  if(scalar @files == 1) {
    my $file = $files[0];
	$file =~ /(\d+)/;
	my $score = $1;
	printRun("move $home\\gen\\$file $home\\gen\\pr-${score}-normal-$k.txt");
  }
  else {
	  die("Did not find exactly one proper result file.");
  }
}
